package com.hbean.controller;

import com.github.pagehelper.PageInfo;
import com.hbean.entity.SysLog;
import com.hbean.service.SysLogService;
import com.hbean.system.config.Base;
import com.hbean.utils.Condition;
import com.hbean.utils.HUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @Description: null
 * @Project: hbean
 * @Author: hjibo
 * @CreateDate: 2018-10-28 22:52
 * @ModificationHistory:
 */

@Slf4j
@RestController
@RequestMapping("/sysLog")
public class SysLogController extends Base {

    @Autowired
    private SysLogService sysLogService;

    /**
     * description: 查询
     * create_user: hjibo
     * create_date: 2018-09-29 10:13
     * param :
     */
    @RequestMapping("/getSysLogs")
    public Map getSysDics(HttpServletRequest request){
        List<SysLog> list = null;
        try {
            //查询条件
            Condition condition = new Condition();
            condition.setParam11(request.getParameter("page"));//页码
            condition.setParam12(request.getParameter("limit"));//每页显示数量

            if(HUtil.isNotEmpty(request.getParameter("sl00"))) condition.setParam1(request.getParameter("sl00"));//主键
            if(HUtil.isNotEmpty(request.getParameter("startTime"))) condition.setParam2(request.getParameter("startTime") + " 00:00:00");//开始时间
            if(HUtil.isNotEmpty(request.getParameter("endTime"))) condition.setParam3(request.getParameter("endTime") + " 23:59:59");//结束时间
            if(HUtil.isNotEmpty(request.getParameter("sl01"))) condition.setParam4(request.getParameter("sl01"));//日志类型

            list = sysLogService.getDatas(condition);

            return mapResult(SUCCESS_CODE,SUCCESS_MSG,new PageInfo<>(list).getTotal(),list);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return mapResult(ERROR_CODE,ERROR_MSG,LONG_0L,null);
    }

}
